package com.anosine.gpsl.android.impl;

import com.anosine.gpsl.android.AppConstants;
import com.anosine.gpsl.android.WebConstants;
import com.anosine.gpsl.android.dao.ActivieListDao;
import com.anosine.gpsl.android.dao.FamilyNumberListDao;
import com.anosine.gpsl.android.entity.ActiveList;
import com.anosine.gpsl.android.entity.FamilyNumberList;
import com.anosine.gpsl.android.presenter.BasePresenterActivity.OnLoadListener;
import com.anosine.gpsl.android.util.HttpRequestListener;
import com.anosine.gpsl.android.util.SendHttpUtils;
import com.anosine.gpsl.android.util.ToastHelper;
import com.google.gson.reflect.TypeToken;
import com.lidroid.xutils.http.RequestParams;

/**
 * @Title: FamilyNumberListDaoImpl
 * @Package com.anosine.gpsl.android.impl
 * @Description: 接口实现
 * @author: sunny
 * @date: 2015-12-14
 * @version V1.0
 */
public class FamilyNumberListDaoImpl  implements FamilyNumberListDao {
	private OnLoadListener loadListener;

	/**
	 * @Title: FamilyNumberListDaoImpl(OnLoadListener loadListener)
	 * @Description: 构造方法，初始化对象，给loadListener赋值
	 * @param: loadListener
	 * @throws
	 */

	public FamilyNumberListDaoImpl(OnLoadListener loadListener) {
		super();
		this.loadListener = loadListener;
	}

	/**
	 * @Title:getFamilyNumberList(String usermd5)
	 * @Description: 调用亲情号列表接口
	 * @param usermd5 登录验证串
	 * @return: 无
	 * @throws
	 */

	@Override
	public void getFamilyNumberList(String usermd5){

		RequestParams params = new RequestParams();
		params.addBodyParameter("usermd5", usermd5);
		SendHttpUtils sendHttp = new SendHttpUtils();
		TypeToken type = new TypeToken<FamilyNumberList>() {
		};
		String url = String.format("%1s/%2s", AppConstants.sCommonUrl,
				WebConstants.Do_GetFamilyNumbers_Action);
		sendHttp.doRequest(url, params, type, new HttpRequestListener<FamilyNumberList>() {
			/**
			 * @Title: onSuccess(String result, FamilyNumberList t)
			 * @Description: 解析成功做的操作
			 * @param: result json
			 * @param: t 
			 * @return: 无
			 * @throws
			 */
			@Override
			public void onSuccess(String result, FamilyNumberList t) {
				
				loadListener.onSuccess(result);

			}
			/**
			 * @Title: onFailure(String error)
			 * @Description: 解析失败做的操作
			 * @param: error 错误信息
			 * @return: 无
			 * @throws
			 */
			@Override
			public void onFailure(String error) {
				loadListener.onFailure();
				ToastHelper.toast(error);
			}
		});

	}

}
